package com.kgis.map.geometry {
    import com.kgis.map.Map;
    import com.kgis.map.common.enum.GeoTypeEnum;
    import com.kgis.map.geometry.basetype.Extent;
    import com.kgis.map.style.IStyle;
    import flash.display.Sprite;
    import mx.collections.ArrayCollection;
    import com.kgis.map.geometry.AbstractGeometry;
    import com.kgis.map.geometry.IAreaComposeGeometry;
    import com.kgis.map.geometry.IGeometry;

    /**
     * 复杂面几何体----多个面组合
     */
    [Bindable]
    [RemoteClass(alias="com.kgis.map.model.geometry.AreaComposeGeometry")]
    public class AreaComposeGeometry extends AbstractGeometry implements IAreaComposeGeometry {
        private var _areaList:ArrayCollection = null;

        public function AreaComposeGeometry() {
            super();
        }

        /**
         * 绘制几何体
         */
        override public function draw(sprite:Sprite, geoStyle:IStyle, map:Map):void {
            return;
        }

        override public function getExtent():Extent {
            var i:int = 0;
            var geoExtent:Extent = new Extent(0, 0, 0, 0);
            geoExtent.xmax = -999999999;
            geoExtent.xmin = 999999999;
            geoExtent.ymax = -999999999;
            geoExtent.ymin = 999999999;

            var subGeo:IGeometry = null;
            for (i = 0; i < this.areaList.length; i++) {
                subGeo = IGeometry(this.areaList.getItemAt(i));
                if (i == 0) {
                    geoExtent = subGeo.getExtent();
                }
                else {
                    geoExtent.extendFromBounds(subGeo.getExtent());
                }
            }
            return geoExtent;
        }

        override public function getGeometryType():int {
            return GeoTypeEnum.POLYGONCOMPOSEGEOMETRY;
        }

        /**简单面集合*/
        public function get areaList():ArrayCollection {
            return _areaList;
        }

        public function set areaList(value:ArrayCollection):void {
            _areaList = value;
        }

    }
}